using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ItemButton : MonoBehaviour,IInitializable<Item>
{
    [SerializeField] private Image iconImage;
    [SerializeField] private Text nameText;
    [SerializeField] private Text countText;

    private Item item;
    private Button button;

    private void Awake()
    {
        button = GetComponent<Button>();
    }
    public void Init(Item itme)
    {
        this.item = itme;
        nameText.text = itme.Data.Name;
        countText.text=item.ItemInfo.count.ToString();
    }
    public void AddButtonEvent(Action action)
    {
        button.onClick.AddListener(()=>action?.Invoke());
    }
    public void UpdateShowPanle(RollUI rollUI)
    {
        button.onClick.RemoveAllListeners();
        button.onClick.AddListener(() =>
        {
            rollUI.ShowPanle(item);
        });
    }

}
